package com.example.enterprise

import com.alibaba.android.arouter.facade.annotation.Route
import com.example.common.view.view.BaseMvvmActivity
import com.example.enterprise.databinding.ActivityEnterpriseDetailBinding
import com.example.enterprise.entity.EnterpriseEntityItem

@Route(path = "/enterprise/EnterpriseDetailActivity")
class EnterpriseDetailActivity : BaseMvvmActivity<ActivityEnterpriseDetailBinding>() {
    override fun getLayoutId(): Int = R.layout.activity_enterprise_detail

    var enterpriseItem: EnterpriseEntityItem? = null

    override fun initView() {
        super.initView()
        enterpriseItem = intent.getParcelableExtra("enterpriseEntity")

        mDataBinding.back.setOnClickListener {
            finish()
        }

        if (enterpriseItem != null)
        // 填充企业信息到界面
            enterpriseItem?.let { item ->
                //"id": 73,
                // 企业名称"name": "狼王科技有限公司",
                mDataBinding.name.text = item.name
                // 行业类型"industryType": "机械科技",
                mDataBinding.industryType.text = item.industryType
                // 所在地址"address": "智慧园区A栋",
                mDataBinding.address.text = item.address
                // 法人代表"legalRepresentative": "狼王",
                mDataBinding.legalRepresentative.text = item.legalRepresentative
                // 联系方式"contactInfo": "13800138000",
                mDataBinding.contactInfo.text = item.contactInfo
                // 企业状态"status": "运营中",
                mDataBinding.status.text = item.status
                // 是否上市"listed": true
                if (item.listed) {
                    mDataBinding.listed.text = "上市中"
                } else {
                    mDataBinding.listed.text = "未上市"
                }
                // 股票名称"stockName": "狼王重工",
                mDataBinding.stockName.text = item.stockName
                // 股票代码"stockCode": "10010",
                mDataBinding.stockCode.text = item.stockCode

                // 照片
                mDataBinding.photos.apply {
                    //"photos": [
                    //"http://example.com/photo1.jpg",
                    //"http://example.com/photo2.jpg"
                    //],
                }
            }
    }
}